#define _CRT_SECURE_NO_WARNINGS
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "user_management_UI.h"
#include "user_management.h"
#include "system_types.h"
int main() {
    SystemData data;
    data.userList = NULL;
    // 初始化角色默认权限
    data.rolePermissions[USER_STUDENT] = 0;
    data.rolePermissions[USER_VIP] = 0;
    data.rolePermissions[USER_COURIER] = PERM_PACKAGE_ADD;
    data.rolePermissions[USER_STAFF] = PERM_PACKAGE_ADD | PERM_PACKAGE_PICKUP | PERM_PACKAGE_QUERY;
    data.rolePermissions[USER_ADMIN] = PERM_ALL;

    int choice;
    do {
        clearScreen();
        showMainMenu();
        printf("\n请输入你的选择: ");
        scanf("%d", &choice);
        switch (choice) {
        case 1:
            handleRegistration(&data);
            break;
        case 2:
            handleLogin(&data);
            break;
        case 3:
            clearScreen();
            printf("=== 退出系统 ===\n\n");
            printf("感谢使用校园智能快递集散系统！\n");
            break;
        default:
            clearScreen();
            printf("=== 错误 ===\n\n");
            printf("无效的选择，请重新输入！\n");
            printf("\n按任意键继续...");
            getchar(); getchar();
            break;
        }
    } while (choice != 3);

    // 释放内存
    User* current = data.userList;
    User* next;
    while (current != NULL) {
        next = current->next;
        free(current);
        current = next;
    }
    return 0;
}